package com.zjut.azhen.DBDesign.config;

import com.zjut.azhen.DBDesign.component.AdminHandlerInterceptor;
import com.zjut.azhen.DBDesign.component.FilterConfig;
import com.zjut.azhen.DBDesign.component.LoginHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MyMVCConfig implements WebMvcConfigurer {
@Autowired
    private LoginHandlerInterceptor loginInterceptor;
@Autowired
    private AdminHandlerInterceptor adminHandlerInterceptor;
@Autowired
    private FilterConfig filterConfig;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 自定义拦截器，添加拦截路径和排除拦截路径
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/auth/**");
        registry.addInterceptor(adminHandlerInterceptor).addPathPatterns("/admin/**");
        registry.addInterceptor(filterConfig).addPathPatterns("/**");
    }


}
